from app.services.business.gaolu_diagnose.ind.abstract_ind import AbstractInd


class CG_LT_GL_GL04_Zha_V2O5(AbstractInd):
    def get_name(self):
        return "CG_LT_GL_GL04_Zha_V2O5"

    def get_data_source(self):
        return "mysql"

    def get_sql(self, params):
        sql_Zha_V2O5 = """    
            select round(avg(jyh.jyjg),3) as CG_LT_GL_GL04_Zha_V2O5 
            from 
            (select jyh.*,jyt.ph, tqpd.tjsj
            from syn_zl_zl_jyh as jyh ,syn_zl_zl_jyt as jyt ,syn_zl_zl_tqpd as tqpd
            where  jyh.jcxmbm='01005' and jyh.zfbz='0' 
            and jyt.wlbm = 'ZJ003' 
            and SUBSTRING(jyt.ph, 4, 1) = '4' 
            and  jyt.jytid = jyh.jytid 
            and  jyt.ph = tqpd.ph
            and jyh.jyjg NOT LIKE '%#%' 
            and tqpd.tjsj > DATE_SUB(CURTIME(), INTERVAL 0.6 hour)) as jyh  

        """.format(**params)
        return sql_Zha_V2O5
